<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浮动特性</title>
    <style>
        .father {
            width: 50%;
            margin: 0 auto;
            background-color: grey;
        }

        .son1 {
            width: 100px;
            height: 100px;
            background-color: red;
            float: left;
        }

        .son2 {
            width: 100px;
            height: 100px;
            background-color: greenyellow;
            float: right;
        }
    </style>
</head>

<body>
    <div class="father">
        <div class="son1"></div>
        <div class="son2"></div>
    </div>

</body>

</html>